var data=[
    {
        "image":"https://cp1.douguo.com/upload/caiku/2/1/d/yuan_214e7a414ea76f3d2b5fbecb33005f9d.jpg",
        "num":"1",
        "text":"准备好食材，手抓饼放软一点",
    },
    {
        "image":"https://cp1.douguo.com/upload/caiku/7/9/8/yuan_793bc68b054bcd22591d9e6b61639098.jpg",
        "num":"2",
        "text":"香蕉剥皮放在手抓饼上面 ",
    },
    {
        "image":"https://cp1.douguo.com/upload/caiku/4/2/d/yuan_421b0c3694cc42abf5e63e385133723d.jpg",
        "num":"3",
        "text":"然后卷起来 ",
    },
    {
        "image":"https://cp1.douguo.com/upload/caiku/a/4/d/yuan_a4897da7d4d84b89643add20a999b38d.jpg",
        "num":"4",
        "text":"切成小块 ",
    },
    {
        "image":"https://cp1.douguo.com/upload/caiku/3/2/1/yuan_323ea6e10504fe1285e236943dee9c91.jpg",
        "num":"5",
        "text":"立起来摆在垫有锡纸的烤盘中  ",
    },
    {
        "image":"https://cp1.douguo.com/upload/caiku/9/c/5/yuan_9cf4349182ebbca625fe41c9dda47f75.jpg",
        "num":"6",
        "text":"刷一层蛋液 ",
    },
    {
        "image":"https://cp1.douguo.com/upload/caiku/5/0/f/yuan_50e89f3eed76327cc0ead9e232bd7b3f.jpg",
        "num":"7",
        "text":"撒点黑芝麻，放入烤箱，烤箱不需要预热  ",
    },
    {
        "image":"https://cp1.douguo.com/upload/caiku/5/0/f/yuan_50e89f3eed76327cc0ead9e232bd7b3f.jpg",
        "num":"8",
        "text":"烤箱，设置温度200°时间15分钟",
    },
    {
        "image":"https://cp1.douguo.com/upload/caiku/f/8/9/yuan_f8b32ce83ff8d9bdd5d6b6939275c2a9.jpg",
        "num":"9",
        "text":"做好啦，外酥里软，超级好吃，隔壁的小孩都馋哭了 ",
    },]



    window.onload = function () {
            
        initData()
    }
    $(function () {
        $('.watch').on('click', function () {
            if ($('.watch').hasClass('test')) {
                $('.watch').removeClass('test').addClass('active');
                $('.watch').val("已关注")
            } else if ($('.watch').hasClass('active')) {
                $('.watch').removeClass('active').addClass('test');
                $('.watch').val("+关注")
            }
        })
        var comment
        var discuss = document.getElementById('discuss')
        var publish = document.getElementById('publish')
        var ping = document.getElementById('ping')
        publish.onclick = function(){
            comment = ping.value
            var newDiv1 = document.createElement('div')
            newDiv1.className = "d1"
            newDiv1.innerHTML = `<hr>
                                <img src="images/default.jpg"><span class="span3">userName</span>
                                <p>`+comment+`</p>
                                <span class="span2">1天前</span>`
            discuss.appendChild(newDiv1)
            ping.value = ""
            //获取姓名
            var userInfo1=[]
            if( localStorage['userInfo']){
                userInfo1=JSON.parse(localStorage['userInfo'])
                document.querySelector('.span3').innerHTML=userInfo1[0].name
            }
        
        }
    })

    function initData() {
        var ul = document.getElementById('make')
        var strHTML = ''
        for (var i = 0; i <=10; i++) {
            if (data[i]) {
                strHTML += `
                <li> <img src="${data[i].image}" alt="">
                     <h4>步骤<b>${data[i].num}</b> </h4> 
                      <p>${data[i].text} </p>
                </li>`

            }
        }
        ul.innerHTML = strHTML
    }